<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="img/favicon.png">

    <title>Chi tiết đơn hàng</title>

    <!-- Bootstrap core CSS -->
    <link href="<?php echo base_url() ?>/Resources/Admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo base_url() ?>/Resources/Admin/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="<?php echo base_url() ?>/Resources/Admin/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="<?php echo base_url() ?>/Resources/Admin/css/style.css" rel="stylesheet">
    <link href="<?php echo base_url() ?>/Resources/Admin/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">
      <!--header start-->
      <header class="header white-bg">
          <?php $this->load->view('admin_layout/header') ?>
          </div>
      </header>
      <!--header end-->
      <!--sidebar start-->
      <aside>
          <div id="sidebar"  class="nav-collapse ">
              <!-- sidebar menu start-->
              <?php $this->load->view('admin_layout/sidebar') ?>
              <!-- sidebar menu end-->
          </div>
      </aside>
      <!--sidebar end-->
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!-- invoice start-->
              <section>
                  <div class="panel panel-primary">
                      <!--<div class="panel-heading navyblue"> INVOICE</div>-->
                      <div class="panel-body">
                          <div class="row invoice-list">
                              <div class="text-center corporate-id">
                                  <label>Thông tin đơn hàng</label>
                              </div>
                              <div class="col-lg-4 col-sm-4">
                                  <h4>Thông tin người nhận</h4>
                                  <p>
                                     Tên khách hàng: <?php echo $user->FULL_NAME ?> <br/>
                                     UserName: <?php echo $user->USERNAME ?> <br/>
                                     Email: <?php echo $user->EMAIL ?> <br/>
                                     Số điện thoại: <?php echo $user->PHONE_NUMBER ?>
                                  </p>
                              </div>
                              <div class="col-lg-4 col-sm-4">
                                  <h4>Chi tiết</h4>
                                  <p>
                                      
                                  </p>
                              </div>
                              <div class="col-lg-4 col-sm-4">
                                  <h4>INVOICE INFO</h4>
                                  <ul class="unstyled">
                                      <li>Invoice Number		: <strong> <?php echo $invoice[0]->INVOICE_ID ?> </strong></li>
                                      <li>Invoice Date:	<?php echo $invoice[0]->START_DATE ?></li>
                                      <li>Due Date:	<?php if($invoice[0]->INVOICE_STATUS != 12) echo 'Đơn hàng chưa xử lý xong'; else echo $invoice[0]->END_DATE ?></li>
                                      <li>Invoice Status: <?php 
                                        
                                        switch($invoice[0]->INVOICE_STATUS)
                                        {
                                           case 1: echo 'Chưa thanh toán';  break;
                                           case 2: echo 'Đã thanh toán';  break;
                                           case 3: echo 'Đã thanh toán > Đang xử lí';  break;
                                           case 4: echo 'Đã thanh toán > Shipping'; break;
                                           case 5: echo 'Đã thanh toán > Đã xử lí > Chờ nhận hàng ';  break;
                                           case 6: echo 'Đã giao hàng '; break;
                                           case 7: echo 'Thanh toán an toàn (3 ngày) ';  break;
                                           case 8: echo 'Delay (Hết hàng, khách bị ban trade,...) ';  break;
                                           case 9: echo 'Pre-order'; break;
                                           case 10: echo 'Pre-order 1';  break;
                                           case 11: echo 'Pre-order 2';  break;
                                           case 12: echo 'Đã hoàn tất'; break;
                                           case 0: echo 'Đã hủy'; break;
                                        }
                                        
                                      
                                      
                                        ?> </li>
                                  </ul>
                              </div>
                          </div>
                          <table class="table table-striped table-hover">
                              <thead>
                              <tr>
                                  <th>#</th>
                                  <th>Item</th>
                                  <th class="">Unit Cost</th>
                                  <th class="">Quantity</th>
                                  <th>Sub-Total</th>
                              </tr>
                              </thead>
                              <tbody>
                              <?php if(isset($detail))
                              {
                                $num = 1;
                                foreach($detail as $items)
                                {
                                    
                                
                               ?>
                              <tr>
                                  <td><?php  echo $num; ?></td>
                                  <td><?php 
                                  $item = $this->m_item->get_item_by_id($items->ITEM_ID);
                                  echo $item->ITEM_NAME ?></td>



                                  <td class="">
                                  <?php if($items->PRICE != '') {$saleoff = 1;
                                if($items->IS_SALE == 0)
                                {
                                    $sample_data = $this->m_item->get_new_saleoff_chung();
                                    $saleoff = $sample_data[0]->SAMPLE_VALUE;
                                }
                                else if($items->IS_SALE == 1)
                                {
                                    $saleoff = $this->m_item->get_new_saleoff_by_itemid($masp);
                                }
                                echo $items->PRICE * $saleoff ;} else {$saleoff = 1;
                                if($items->IS_SALE == 0)
                                {
                                    $sample_data = $this->m_item->get_new_saleoff_chung();
                                    $saleoff = $sample_data[0]->SAMPLE_VALUE;
                                }
                                else if($items->IS_SALE == 1)
                                {
                                    $saleoff = $this->m_item->get_new_saleoff_by_itemid($masp);
                                }
                                echo $items->PRICEVN * $saleoff;} ?></td>
                                  <td class=""><?php echo $items->QUANTITY ?></td>
                                  <td><?php if($items->PRICE != '') {$saleoff = 1;
                                if($items->IS_SALE == 0)
                                {
                                    $sample_data = $this->m_item->get_new_saleoff_chung();
                                    $saleoff = $sample_data[0]->SAMPLE_VALUE;
                                }
                                else if($items->IS_SALE == 1)
                                {
                                    $saleoff = $this->m_item->get_new_saleoff_by_itemid($masp);
                                }
                                echo $items->PRICE * $items->QUANTITY * $saleoff ;} else {$saleoff = 1;
                                if($items->IS_SALE == 0)
                                {
                                    $sample_data = $this->m_item->get_new_saleoff_chung();
                                    $saleoff = $sample_data[0]->SAMPLE_VALUE;
                                }
                                else if($items->IS_SALE == 1)
                                {
                                    $saleoff = $this->m_item->get_new_saleoff_by_itemid($masp);
                                }
                                echo $items->PRICEVN * $items->QUANTITY * $saleoff;} ?></td>
                              </tr>
                              <?php $num++;  }
                              }
                               ?>
                              </tbody>
                          </table>
                          <div class="row">
                          <div class="col-lg-4">
                          <form method="POST" action="<?php echo base_url('invoice/update_don_hang') ?>">
                               <textarea class="form-control" name="decrip" placeholder="Nội dung chi tiết"  rows="4"></textarea>
                          </div>
                          <div class="col-lg-4">
                                 <select id="status" class="form-control" name="status">
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '1') echo "selected=selected"; ?> value="1"> Chưa thanh toán  </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '2') echo "selected=selected"; ?> value="2">  Đã thanh toán </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '3') echo "selected=selected"; ?> value="3"> Đã thanh toán > Đang xử lí  </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '4') echo "selected=selected"; ?> value="4">  Đã thanh toán > Shipping </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '5') echo "selected=selected"; ?> value="5"> Đã thanh toán > Đã xử lí > Chờ nhận hàng  </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '6') echo "selected=selected"; ?> value="6"> Đã giao hàng  </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '7') echo "selected=selected"; ?> value="7">  Thanh toán an toàn (3 ngày) </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '8') echo "selected=selected"; ?> value="8">  Delay </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '9') echo "selected=selected"; ?> value="9"> Pre-order </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '10') echo "selected=selected"; ?> value="10">  Pre-order 1 </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '11') echo "selected=selected"; ?> value="11"> Pre-order 2  </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '12') echo "selected=selected"; ?> value="12"> Đã hoàn tất  </option>
                                         <option <?php if($invoice[0]->INVOICE_STATUS  == '0') echo "selected=selected"; ?> value="0"> Đã hủy  </option>
                                 </select>
                          </div>
                              <div class="col-lg-4 invoice-block pull-right">
                                  <ul class="unstyled amounts">

                                      <li><strong>Grand Total :</strong> <?php echo $invoice[0]->TOTAL ?> </li>
                                  </ul>
                              </div>
                          </div>
                          <br />
                          <div class="text-center invoice-btn">
                          <input type="hidden" name="invoiceid" value="<?php echo $invoice[0]->INVOICE_ID; ?>" />
                              <button type="submit" name="xuly" value="1" onclick="alert('Đã cập nhật')" class="btn btn-info btn-lg"><i class="icon-check"></i> Xử lý </button>
                          </div>
                      </div>
                  </div>
              </section>
              <!-- invoice end-->
          </section>
      </section>
      <!--main content end-->
      <!--footer start-->
      <footer class="site-footer">
         <?php $this->load->view('admin_layout/footer') ?>
      </footer>
      <!--footer end-->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="<?php echo base_url() ?>/Resources/Admin/js/jquery.js"></script>
    <script src="<?php echo base_url() ?>/Resources/Admin/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="<?php echo base_url() ?>/Resources/Admin/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="<?php echo base_url() ?>/Resources/Admin/js/jquery.scrollTo.min.js"></script>
    <script src="<?php echo base_url() ?>/Resources/Admin/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="<?php echo base_url() ?>/Resources/Admin/js/respond.min.js" ></script>

    <!--common script for all pages-->
    <script src="<?php echo base_url() ?>/Resources/Admin/js/common-scripts.js"></script>


  </body>
</html>